package lesson01;

/**
 * 实现Runnable接口创建线程
 *
 * @author wileda
 * @date 2023/01/03  17:05
 */
public class Demo03 {
    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        //第一条线程
        Thread thread = new Thread(myRunnable);
        //第二条线程
        Thread thread01 = new Thread(myRunnable);
        thread.start();
        while(true){
            System.out.println("main Thread ...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
class MyRunnable implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("MyRunnable Thread ...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}